<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>生命体征记录-header</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <style>
        ul li,
        ul li div div select,
        ul li div div input {
            font-size: 14px !important;
            ;
        }

        .aui-list-item-label {
            width: 220px !important;
            text-align: center;
        }

        .aui-list-item-input-small {
            width: 140px !important;
            position: relative;
        }

        .aui-list-item-input-small>input {
            width: 90px;
        }

        .aui-list-item-input-small>span {
            position: absolute;
            display: inline-block;
            height: 30px;
            top: 50%;
            right: 0;
            transform: translateY(-50%);
        }

        .aui-list-item-label-width {
            width: 530px !important;
        }

        .aui-list-item-input>label {
            margin-left: 10px;
        }

        .aui-radio {
            margin-right: 10px;
        }

        .aui-radio,
        .aui-checkbox {
            width: 25px !important;
            height: 25px !important;
            margin-right: 5px;
        }

        .textarea-container {
            width: 100%;
            margin: 0 auto;
        }

        .textarea-container>div:nth-child(1) {
            text-align: center;
            font-size: 17px;
        }

        .textarea-container>div:nth-child(2) {
            padding: 10px;
        }

        .textarea-wrapper {
            min-height: 100px;
            border: 1px solid rgba(0, 0, 0, 0.3);
            width: 97%;
            margin: 20px auto 5px auto;
            border-radius: 5px;
        }

        .submit-btn-bottom {
            font-size: 16px;
            margin: 30px auto;
            text-align: center;
        }

        .submit-btn-bottom>button {
            border: none;
            outline: none;
            background-color: #0064B0;
            height: 50px;
            width: 150px;
            color: #fff;
        }
    </style>
</head>

<body>
    <br>
    <main id="app">
        <header id="header" class="aui-bar aui-bar-nav">
            <a class="aui-pull-left aui-btn" onclick="closewin()">
                <span class="aui-iconfont aui-icon-left"></span>
            </a>
            <div class="aui-title">生命体征记录</div>
        </header>
        <section class="hospital">

        </section>
    </main>
</body>

<body>
    <main id="app">
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            体温
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="体温" id="vsTemperature">
                        </div>
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            脉搏/心率
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="脉搏/心率" id="vsPulse">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            呼吸
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" id="vsBreathing" placeholder="呼吸">
                        </div>
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            舒张压
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" id="vsDiastolic" placeholder="舒张压">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            血氧饱和
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" id="vsBloodOxygenSatur" placeholder="血氧饱和">
                        </div>
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            收缩压
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" id="vsSystolic" placeholder="收缩压">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            日期：
                        </div>
                        <div class="aui-list-item-input" id="vsTime">
                        </div>
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            签名
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" id="vsAutograph" placeholder="签名">
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div>
            <div class="submit-btn-bottom">
                <button id="Preservatio" onclick="HoVitalSigns()">保存</button>
            </div>
        </div>
    </main>
</body>

</html>

<script src="../script/api.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/vue.js" charset="utf-8" type="text/javascript"></script>
<script src="../js/jquery.min.js" charset="utf-8" type="text/javascript"></script>
<script src="../js/ToConfigure.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-toast.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-dialog.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-tab.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript">

var vm;
    apiready = function () {
        vm = new Vue({
            el: '#app',
            data: {
                getDateTime: '选择日期'
            },
            created() {

            },
            watch: {
                searchInfo: function () { }
            },
            methods: {

            },
        })
    }

    // function getDateTime() {
    //     api.openPicker({
    //         type: 'date_time',
    //         title: '选择开始日期'
    //     }, function (ret, err) {
    //         if (ret) {
    //             var year = ret.year;
    //             var month = ret.month;
    //             var day = ret.day;
    //             vm.getDateTime = '' + year +
    //                 '-' + month +
    //                 '-' + day
    //         }
    //     });
    // }
        /**
      * 获取当前时间
      */
//获取当前时间
function getNowFormatDate() {

var date = new Date();

var seperator1 = "-";

var seperator2 = ":";

var month = date.getMonth() + 1;

var strDate = date.getDate();

if (month >= 1 && month <= 9) {

    month = "0" + month;

}

if (strDate >= 0 && strDate <= 9) {

    strDate = "0" + strDate;

}

var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate

    + " " + date.getHours() + seperator2 + date.getMinutes()

    + seperator2 + date.getSeconds();

return currentdate;

}

    // function getDateTime() {
    //     api.openPicker({
    //         type: 'date',
    //         title: '选择开始日期'
    //     }, function (ret, err) {
    //         if (ret) {
    //             var month = ret.month > 9 ? ret.month : '0' + ret.month;
    //             var day = ret.day > 9 ? ret.day : '0' + ret.day;
    //             vm.getDateTime = '' + ret.year +
    //                 '-' + month +
    //                 '-' + day
    //         }
    //     });
    // }
    /**
     * 加载当前信息
     * */
    window.apiready = function () {
        /**
         * 判断当前唯一ID是否大于0
         * */
        if(api.pageParam.vsId > 0){
            /**
             * 查询当前信息
             * */
            getHoVitalSigns();
        }
    }; 

    function HoVitalSigns() {
        if (api.pageParam.vsId > 0) {
            /**
             * 修改生命体征记录
             * 
             * */
            updateHoVitalSigns();
        } else {
            /**
             * 添加生命体征记录
             * 
             * */
            insertHoVitalSigns();
        }
    }
    /**
     * 添加巡检记录
     */
    function insertHoVitalSigns() {
        var toast = new auiToast();
        //获取所属医院IP地址
        var Url_IP = ToConfigure_IP("Gorgeous");
        /**
         * 参数
         * 
         * */
        var JsonStr = GetParameters();

        console.log(JsonStr);
        /**
                 * 请求控制器
                 */
        $.ajax({
            url: Url_IP + '/businessmanagement/vitalsigns/insertHoVitalSigns',
            type: 'post',
            contentType: "application/json",
            dataType: "json",
            data: JsonStr,
            success: function (result) {

                /**
                 * 验证返回信息是否为空
                 */
                if (result.success == true) {
                    /**
                     * 操作成功提醒
                     */
                    JumpPage();
                } else {
                    /**
                     *  提示错误信息
                     */
                    toast.fail({
                        title: "提交失败",
                        duration: 2000
                    });
                   
                }
            },
            error: function (result) {
                /**
                 *  提示错误信息
                 */
                toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
            }
        })

    }

     /**
     * 修改巡检记录
     */
     function updateHoVitalSigns() {
        var toast = new auiToast();
        //获取所属医院IP地址
        var Url_IP = ToConfigure_IP("Gorgeous");
        /**
         * 参数
         * 
         * */
        var JsonStr = GetParameters();

        console.log(JsonStr);
        /**
          * 请求控制器
          */
        $.ajax({
            url: Url_IP + '/businessmanagement/vitalsigns/updateHoVitalSigns',
            type: 'post',
            async: false,
            contentType: "application/json",
            dataType: "json",
            data: JsonStr,
            success: function (result) {

                /**
                 * 验证返回信息是否为空
                 */
                if (result.success == true) {
                    JumpPage();
                } else {
                    /**
                     *  提示错误信息
                     */
                    toast.fail({
                        title: "提交失败",
                        duration: 2000
                    });
                }
            },
            error: function (result) {
                /**
                 *  提示错误信息
                 */
                toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
            }
        })

    }

    /**
 * 查询巡检记录信息
 * @param currPage 褰撳墠椤�
 */
function getHoVitalSigns() {
    var toast = new auiToast();
        //获取所属医院IP地址
    var Url_IP = ToConfigure_IP("Gorgeous");
    /**
     * 实例化
     * @type {Object}
     */
    var jsParms = new Object();
    /**
     * 唯一ID
     * @type {jQuery}
     */
    jsParms.vsId = api.pageParam.vsId;
    /**
     * 璇锋眰鎺у埗鍣�
     */
    $.ajax({
        url: Url_IP + '/businessmanagement/vitalsigns/getHoVitalSigns',
        type: 'post',
        async: false,
        contentType: "application/json",
        dataType: "json",
        data: JSON.stringify(jsParms),
        success: function (result) {
            /**
             * 楠岃瘉杩斿洖淇℃伅鏄惁涓虹┖
             */
            if (result.success == true) {
                $.each(result.data.list, function (i, o) {
                    /**
                     *
                     */
                    $("#vsTemperature").val(o.vsTemperature);
                    /**
                     *
                     */
                    $("#vsPulse").val(o.vsPulse);
                    /**
                     *
                     */
                    $("#vsBreathing").val(o.vsBreathing);
                    /**
                     *
                     */
                    $("#vsBloodPressure").val(o.vsBloodPressure);
                    /**
                     *
                     */
                    $("#vsBloodOxygenSatur").val(o.vsBloodOxygenSatur);
                    /**
                     *
                     */
                    $("#vsDiastolic").val(o.vsDiastolic);
                    /**
                     *
                     */
                    $("#vsSystolic").val(o.vsSystolic);
                    /**
                     *
                     */
                    $("#vsAutograph").val(o.vsAutograph);
                    /**
                     *
                     */
                    $("#vsTime").text(o.vsTime);
                })
            } else {
                /**
                 *  提示错误信息
                 */
                 toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
            }
        },
        error: function (result) {
           /**
                 *  提示错误信息
                 */
                 toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
        }
    })
}
    //跳转页面
    function JumpPage() {
        var dialog = new auiDialog();
        dialog.alert({
            title: "提示",
            msg: '操作成功，是否跳转',
            buttons: ['取消', '确定']
        }, function (ret) {
            if (ret.buttonIndex === 1) {

            } else if (ret.buttonIndex === 2) {
                api.historyBack({}, function (ret, err) {

                    if (!ret.status) {
                        api.closeWin();
                    }
                });

                api.sendEvent({
                    name: 'On_Site_Inspection',
                    extra: {
                        state: 'no'
                    }
                });
            }
        })
    }

    function GetParameters() {
        var jsParms = new Object();
        if(api.pageParam.vsId>0){
        /**
         * 
         * 患者治疗登记
         * */
         jsParms.vsId = api.pageParam.vsId;
        }
        /**
        }
        /**
         * 
         * 患者治疗登记
         * */
        jsParms.vsTrId = api.pageParam.F_ID;
        /**
         *
         */
        jsParms.vsTemperature = $("#vsTemperature").val();
        /**
         *
         */
        jsParms.vsPulse = $("#vsPulse").val();
        /**
         *
         */
        jsParms.vsBreathing = $("#vsBreathing").val();
        /**
         *
         */
        jsParms.vsBloodPressure = $("#vsBloodPressure").val();
        /**
         *
         */
        jsParms.vsBloodOxygenSatur = $("#vsBloodOxygenSatur").val();
        /**
         *
         */
        jsParms.vsAutograph = api.pageParam["userName"];
        /**
         *
         */
        jsParms.vsDiastolic = $("#vsDiastolic").val();
        /**
         *
         */
        jsParms.vsSystolic = $("#vsSystolic").val();
        /**
         *
         */
        jsParms.vsTime = (getNowFormatDate());

        return JSON.stringify(jsParms);
    }

    function closewin() {
        api.closeWin({
            name: 'Patient_Vital_Signs_Form'
        });
    }

</script>